<template>
    <div>
        <!--品相测定-查询 -->
        <el-form :inline="true" :model="form" class="demo-form-inline">
        <el-form-item label="羊只耳号">
        <el-select v-model="form.Earbugles" style="width: 220px" clearable>
            <el-option label="全部" :value="0"></el-option>
                <el-option
                v-for="item in ear"
                 :key="item.id"
              :label="item.name"
              :value="item.name"
                />
            </el-select>
        </el-form-item>
        <el-form-item label="品&nbsp;&nbsp;&nbsp;&nbsp;种">
            <el-select v-model="form.Breed" clearable>
            <el-option label="全部" :value="0"></el-option>
            <el-option
                v-for="item in BreedList"
                :key="item.value"
                :label="item.name"
                :value="item.value"
            />
            </el-select>
        </el-form-item>
        <el-form-item label="性&nbsp;&nbsp;&nbsp;&nbsp;别">
            <el-select v-model="form.Sex" clearable>
            <el-option label="全部" :value="0"></el-option>
            <el-option
                v-for="item in SexList"
                :key="item.value"
                :label="item.name"
                :value="item.value"
            />
            </el-select>
        </el-form-item>
        <el-form-item>
            <el-button type="danger" @click="GetConditionMeasure">查询</el-button>
            <el-button>重置</el-button>
        </el-form-item>
        </el-form>
        <el-divider />
        <el-button type="danger" @click="dialogFormVisible = true">新增</el-button>
        <el-button type="danger" @click="BatchDel()">删除</el-button>
        <br />
        <br />
        <div v-if="TagBool">
            <el-tag style="width:1920px;color: black;height: 50px;" type="danger" :iocn="Delete">
                <spna style="font-size: 15px">
                    <Warning style="width: 1em; height: 1em; margin-right: 8px" color="red" />
                    <span style="margin-right: 1800px">已选择 {{ TagCount }} 项</span>
                </spna>
            </el-tag>
        </div>
        <div v-else>
            <el-tag style="width:1920px;color: black;height: 50px;" type="success" :iocn="Delete">
                <spna style="font-size: 15px">
                    <SuccessFilled style="width: 1em; height: 1em; margin-right: 8px" color="green" />
                    <span style="margin-right: 1800px">已选择 {{ TagCount }} 项</span>
                </spna>
            </el-tag>
        </div>
        <br />
        <!--体尺测定-列表 -->
        <el-table :data="ConditionMeasureList" stripe style="width: 100%" border @selection-change="handleSelectionChange">
        <el-table-column type="selection" align="center" />
        <el-table-column label="序号" :fixed="true" width="110px">
            <template v-slot="a">
            <span>{{ a.$index + (page.pageIndex - 1) * page.pageSize + 1 }}</span>
            </template>
        </el-table-column>
        <el-table-column prop="Earbugles" label="耳号" :fixed="true"  width="110px" />
        <el-table-column prop="Breed" label="品种" width="110px">
            <template v-slot="data">
            <span v-if="data.row.Breed == 1">杜泊</span>
            <span v-else-if="data.row.Breed == 2">澳洲白 </span>
            <span v-else-if="data.row.Breed == 3">萨福克</span>
            <span v-else-if="data.row.Breed == 4">杜湖</span>
            <span v-else-if="data.row.Breed == 5">杜杜湖</span>
            <span v-else-if="data.row.Breed == 6">萨杜湖</span>
            <span v-else-if="data.row.Breed == 7">澳湖</span>
            <span v-else-if="data.row.Breed == 8">湖羊</span>
            <span v-else>澳杜湖</span>
            </template>
        </el-table-column>
        <el-table-column prop="Sex" label="性别" width="110px">
            <template v-slot="data">
              <span v-if="data.row.Sex == 1">公</span>
              <span v-else>母</span>
            </template>
        </el-table-column>
        <el-table-column prop="MeasureCottage" label="当前栋舍" width="110px"/>
        <el-table-column prop="MeasureField" label="当前栏位" width="110px"/>
        <el-table-column prop="MeasureDate1" label="测定日期" width="110px">
            <template v-slot="scope">
            <span>{{
                scope.row.MeasureDate1
                ? scope.row.MeasureDate1.replace("T", " ").substring(0, 10)
                : null
            }}</span>
            </template>
        </el-table-column>  
        <el-table-column prop="AgeDay" label="测定日龄" width="110px"/>
        <el-table-column prop="ToothType" label="牙齿咬合" width="110px">
          <template v-slot="data">
          <span v-if="data.row.ToothType==1">正常</span>
          <span v-if="data.row.ToothType==2">错齿</span>
          </template>
        </el-table-column>
        <el-table-column prop="Hairs" label="毛发" width="110px">
          <template v-slot="data">
          <span v-if="data.row.Hairs==1">一分</span>
          <span v-if="data.row.Hairs==2">二分</span>
          <span v-if="data.row.Hairs==3">三分</span>
          </template>
        </el-table-column>
        <el-table-column prop="Stain" label="色斑" width="110px">
          <template v-slot="data">
          <span v-if="data.row.Stain==1">一分</span>
          <span v-if="data.row.Stain==2">二分</span>
         <span v-if="data.row.Stain==3">三分</span>
          </template>
        </el-table-column>
        <el-table-column prop="HoofColor" label="蹄颜色" width="110px">
          <template v-slot="data">
          <span v-if="data.row.HoofColor==1">一分</span>
          <span v-if="data.row.HoofColor==2">二分</span>
          <span v-if="data.row.HoofColor==3">三分</span>
          </template>
        </el-table-column>
        <el-table-column prop="MouthColor" label="嘴颜色" width="110px">
          <template v-slot="data">
          <span v-if="data.row.MouthColor==1">一分</span>
          <span v-if="data.row.MouthColor==2">二分</span>
          <span v-if="data.row.MouthColor==3">三分</span>
          </template>
        </el-table-column>
        <el-table-column prop="Angle" label="角" >
          <template v-slot="data">
          <span v-if="data.row.Angle==1">有角</span>
          <span v-if="data.row.Angle==2">无角</span>
          </template>
        </el-table-column>
        <el-table-column prop="FatFound" label="脂肪分布" width="110px" >
          <template v-slot="data">
          <span v-if="data.row.FatFound==1">一分</span>
          <span v-if="data.row.FatFound==2">二分</span>
         <span v-if="data.row.FatFound==3">三分</span>
          </template>
        </el-table-column>
        <el-table-column prop="CreateBy" label="创建人" width="110px"/>
        <el-table-column prop="CreateDate" label="创建时间" width="110px">
            <template v-slot="scope">
            <span>{{
                scope.row.CreateDate
                ? scope.row.CreateDate.replace("T", " ").substring(0, 10)
                : null
            }}</span>
            </template>
        </el-table-column>
        <el-table-column prop="UpdateBy" label="修改人" width="110px"/>
        <el-table-column prop="UpdateDate" label="修改时间" width="110px">
            <template v-slot="scope">
            <span>{{
                scope.row.UpdateDate
                ? scope.row.UpdateDate.replace("T", " ").substring(0, 10)
                : null
            }}</span>
            </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" width="110px">
            <template v-slot="scope">
            <el-link type="primary" @click="Del(scope.row.CMID)">删除</el-link>
            &nbsp;
            <el-link type="primary" @click="dialogFormVisible1 = true,EditConditionMeasure(scope.row.CMID)" >修改</el-link>
            </template>
        </el-table-column>
        </el-table>
        <!-- 分页 -->
        <div class="demo-pagination-block">
        <el-pagination
            v-model:current-page="page.pageIndex"
            v-model:page-size="page.pageSize"
            :page-sizes="[10, 20, 30, 50]"
            :background="true"
            layout="total, sizes, prev, pager, next, jumper"
            :total="page.totalCount"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
        />
        </div>
        <!-- 新增弹出层 -->
        <el-dialog
          v-model="dialogFormVisible"
          title="基本信息"
          width="60%"
          align-center
        >
          <el-form
            :model="Isform"
            ref="Isruleform"
            style="width: 100%"
            :rules="rules"
            label-width="auto"
            class="demo-ruleForm"
            :size="formSize"
            status-icon
          >
          <el-form-item :label-width="formLabelWidth">
              <el-button type="danger" @click="AddConditionMeasure(Isruleform)">新增</el-button> 
            <el-button type="danger" disabled >保存</el-button> 
            <el-button type="danger" disabled>撤销</el-button> 
            <el-button type="danger" disabled>删除</el-button> 
            </el-form-item>        
          <el-row :gutter="24">
            <el-col :span="12">
            <el-form-item
              label="测定日期:"
              prop="MeasureDate1"
              :label-width="formLabelWidth"
            >
              <el-date-picker
                v-model="Isform.MeasureDate1"
                type="date"
                style="width: 60%"
                value-format="YYYY-MM-DD"
                clearable
              />
            </el-form-item> 
            <el-form-item
              label="牙齿咬合"
              prop="ToothType"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform.ToothType" style="width: 60%" clearable>
                <el-option
                  v-for="item in ToothTypeList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item> 
            <el-form-item
              label="色斑"
              prop="Stain"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform.Stain" style="width: 60%" clearable>
                <el-option
                  v-for="item in StainList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>  
            <el-form-item
              label="嘴颜色"
              prop="MouthColor"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform.MouthColor" style="width: 60%" clearable>
                <el-option
                  v-for="item in MouthColorList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>    
            <el-form-item
              label="脂肪分布"
              prop="FatFound"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform.FatFound" style="width: 60%" clearable>
                <el-option
                  v-for="item in FatFoundList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>         
            </el-col>
            <el-col :span="12">
            <el-form-item
              label="羊只耳号"
              prop="Earbugles"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform.Earbugles" style="width: 60%" clearable @change="EditEar">
                <el-option
                  v-for="item in ear"
                 :key="item.id"
              :label="item.name"
              :value="item.name"
                />
              </el-select>
            </el-form-item>  
            <el-form-item
              label="毛发"
              prop="Hairs"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform.Hairs" style="width: 60%" clearable>
                <el-option
                  v-for="item in HairsList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>   
            <el-form-item
              label="蹄颜色"
              prop="HoofColor"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform.HoofColor" style="width: 60%" clearable>
                <el-option
                  v-for="item in HoofColorList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item
              label="角"
              prop="Angle"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform.Angle" style="width: 60%" clearable>
                <el-option
                  v-for="item in AngleList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>           
            </el-col>
          </el-row>
          </el-form>
        </el-dialog>
        <!-- 修改弹出层 -->
        <el-dialog
          v-model="dialogFormVisible1"
          title="基本信息"
          width="60%"
          align-center
        >
          <el-form
            :model="Isform1"
            ref="Isruleform1"
            style="width: 100%"
            :rules="rules1"
            label-width="auto"
            class="demo-ruleForm"
            :size="formSize"
            status-icon
          >
          <el-form-item :label-width="formLabelWidth">
              <el-button type="danger" disabled>新增</el-button> 
            <el-button type="danger"  @click="UpdConditionMeasure(Isruleform1)" >保存</el-button> 
            <el-button type="danger" disabled>撤销</el-button> 
            <el-button type="danger" disabled>删除</el-button> 
            </el-form-item>        
          <el-row :gutter="24">
            <el-col :span="12">
            <el-form-item
              label="测定日期:"
              prop="MeasureDate1"
              :label-width="formLabelWidth"
            >
              <el-date-picker
                v-model="Isform1.MeasureDate1"
                type="date"
                style="width: 60%"
                value-format="YYYY-MM-DD"
                clearable
              />
            </el-form-item> 
            <el-form-item
              label="牙齿咬合"
              prop="ToothType"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform1.ToothType" style="width: 60%" clearable>
                <el-option
                  v-for="item in ToothTypeList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item> 
            <el-form-item
              label="色斑"
              prop="Stain"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform1.Stain" style="width: 60%" clearable>
                <el-option
                  v-for="item in StainList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>  
            <el-form-item
              label="嘴颜色"
              prop="MouthColor"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform1.MouthColor" style="width: 60%" clearable>
                <el-option
                  v-for="item in MouthColorList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>    
            <el-form-item
              label="脂肪分布"
              prop="FatFound"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform1.FatFound" style="width: 60%" clearable>
                <el-option
                  v-for="item in FatFoundList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>         
            </el-col>
            <el-col :span="12">
            <el-form-item
              label="羊只耳号"
              prop="Earbugles"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform1.Earbugles" style="width: 60%" clearable @change="EditEarEdit">
                <el-option
                  v-for="item in ear"
                  :key="item.id"
              :label="item.name"
              :value="item.name"
                />
              </el-select>
            </el-form-item>  
            <el-form-item
              label="毛发"
              prop="Hairs"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform1.Hairs" style="width: 60%" clearable>
                <el-option
                  v-for="item in HairsList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>   
            <el-form-item
              label="蹄颜色"
              prop="HoofColor"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform1.HoofColor" style="width: 60%" clearable>
                <el-option
                  v-for="item in HoofColorList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item
              label="角"
              prop="Angle"
              :label-width="formLabelWidth"
            >
            <el-select v-model="Isform1.Angle" style="width: 60%" clearable>
                <el-option
                  v-for="item in AngleList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>           
            </el-col>
          </el-row>
          </el-form>
        </el-dialog>
    </div>  
</template>
<script setup lang="ts">
import http from '@/http'
import { ref, reactive, inject, onMounted } from "vue";
import type { AxiosStatic } from "axios";
import { get } from "@vueuse/core";
import type { ComponentSize, FormInstance, FormRules } from "element-plus";
import { ElMessage, ElMessageBox } from "element-plus";
import {
    Plus,
    Search,
    Delete,
    DocumentChecked,
    Back,
    Warning,
    SuccessFilled
} from '@element-plus/icons-vue'
const axios = inject("axios") as AxiosStatic; 

const refs = ref([{ CMID: "" }])

//选中数据
let ids = "";
const TagBool = ref(true);
const TagCount = ref(0);
const handleSelectionChange = (val: refs | any) => {
    refs.value = val;
    ids = "";
    val.forEach(x => {
        ids += x.CMID + ",";
    })
    ids = ids.substring(0, ids.length - 1);
    TagCount.value = ids.split(',').length;
    if (ids == "") {
        TagCount.value = 0;
    }
    if (TagCount.value == 0) {
        TagBool.value = true;
    }
    else {
        TagBool.value = false;
    }
}
//批量删除
const BatchDel=() => {
  let idss = refs.value.map(x=>x.CMID);
  if (refs.value.length == 0) {
    ElMessage.error("至少选择一项");
    return;
  }
   ElMessageBox.confirm("确定要此数据删除吗?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      http
        .post("first/api/Breeding/BatchConditionMeasure?Array="+idss)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息批量删除成功",
            });
           GetConditionMeasure()
          } else {
            ElMessage({
              type: "error",
              message: "信息批量删除失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });

}
//单个删除
const Del = (CMID: any) => {
  ElMessageBox.confirm("确定要此数据删除吗?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      http
        .delete("first/api/Breeding/DelConditionMeasure?CMID=" + CMID)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息删除成功",
            });
            GetConditionMeasure();
          } else {
            ElMessage({
              type: "error",
              message: "信息删除失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });
}
//新增弹出层
const dialogFormVisible = ref(false);
const formLabelWidth = "140px";
const formSize = ref<ComponentSize>("default");
const Isruleform = ref<FormInstance>();
interface RuleForm{
    CMID:Number,
    MeasureDate:Number,
    MeasureDate1: string;
    Earbugles: string;  
    ToothType:string;
    Stain:string;
    MouthColor:string;
    FatFound:string;
    Hairs:string;
    HoofColor:string;
    Angle: string;
    Sex:string,
    Breed: string,
    MeasureCottage: string,
    MeasureField: string,
    AgeDay:number
}
//新增form
const Isform = reactive<RuleForm>({
  CMID:0,
  MeasureDate:0,
  MeasureDate1: "",  
  Earbugles: "",
  ToothType: "",
  Stain: "",
  MouthColor: "",
  FatFound: "",
  Hairs: "",
  HoofColor: "",
  Angle: "",
  Sex:"",
  Breed: "",
  MeasureCottage: "",
  MeasureField: "",
  AgeDay:0
})
//校验
const rules = reactive<FormRules<RuleForm>>({
MeasureDate1: [
{
type: "date",
required: true,
message: "测定日期不能为空",
trigger: "change",
},
],
    Earbugles: [{ required: true, message: "请选择羊只耳号", trigger: "change" }],
    ToothType: [{ required: true, message: "请选择牙齿咬合", trigger: "change" }],
    Stain: [{ required: true, message: "请选择色斑", trigger: "change" }],
    MouthColor: [{ required: true, message: "请选择嘴颜色", trigger: "change" }],
    FatFound: [{ required: true, message: "请选择脂肪分布", trigger: "change" }],
    Hairs: [{ required: true, message: "请选择毛发", trigger: "change" }],
    HoofColor: [{ required: true, message: "请选择蹄颜色", trigger: "change" }],
    Angle: [{ required: true, message: "请选择角", trigger: "change" }],
});
//新增体尺
const AddConditionMeasure = async (formEl: FormInstance | undefined) => {
  if (!formEl) return;
  await formEl.validate((valid, fields) => {
    if (valid) {
      console.log(Isform);
      http.post("first/api/Breeding/AddConditionMeasure", Isform).then((res) => {
        if (res.data > 0) {
          ElMessage({
            message: "品相测定保存成功",
            type: "success",
          });

          dialogFormVisible.value = false;
         GetConditionMeasure();
          formEl.resetFields();
          
        } else {
          ElMessage({
            message: "品相测定保存失败",
            type: "error",
          });
        }
      });
    } else {
      console.log("error submit!", fields);
    }
  });
};
//反填
const dialogFormVisible1 = ref(false);
const Isruleform1 = ref<FormInstance>();
interface RuleForm1{
    CMID:Number,
    MeasureDate:Number,
    MeasureDate1: string;
    Earbugles: string;  
    ToothType:string;
    Stain:string;
    MouthColor:string;
    FatFound:string;
    Hairs:string;
    HoofColor:string;
    Angle: string;
    Sex:string,
    Breed: string,
    MeasureCottage: string,
    MeasureField: string,
    AgeDay:number,
    CreateBy: string,
    CreateDate:string
}
//修改form
const Isform1 = reactive<RuleForm1>({
  CMID:0,
  MeasureDate:0,
  MeasureDate1: "",  
  Earbugles: "",
  ToothType: "",
  Stain: "",
  MouthColor: "",
  FatFound: "",
  Hairs: "",
  HoofColor: "",
  Angle: "",
  Sex:"",
  Breed: "",
  MeasureCottage: "",
  MeasureField: "",
  AgeDay:0,
  CreateBy: "",
  CreateDate:""
})
//校验
const rules1 = reactive<FormRules<RuleForm1>>({
MeasureDate1: [
{
type: "date",
required: true,
message: "测定日期不能为空",
trigger: "change",
},
],
    Earbugles: [{ required: true, message: "请选择羊只耳号", trigger: "change" }],
    ToothType: [{ required: true, message: "请选择牙齿咬合", trigger: "change" }],
    Stain: [{ required: true, message: "请选择色斑", trigger: "change" }],
    MouthColor: [{ required: true, message: "请选择嘴颜色", trigger: "change" }],
    FatFound: [{ required: true, message: "请选择脂肪分布", trigger: "change" }],
    Hairs: [{ required: true, message: "请选择毛发", trigger: "change" }],
    HoofColor: [{ required: true, message: "请选择蹄颜色", trigger: "change" }],
    Angle: [{ required: true, message: "请选择角", trigger: "change" }],
});
const EditConditionMeasure = (CMID:any) => {
  dialogFormVisible1.value = true;
  http.get("srout/api/Breeding/EditConditionMeasure?CMID="+CMID)
    .then(res => {  
      Isform1.CMID = res.data.CMID;  
      Isform1.MeasureDate = res.data.MeasureDate;  
      Isform1.MeasureDate1 = res.data.MeasureDate1;  
      Isform1.Earbugles = res.data.Earbugles;  
      Isform1.ToothType = res.data.ToothType;  
      Isform1.Stain = res.data.Stain;  
      Isform1.MouthColor = res.data.MouthColor;  
      Isform1.FatFound = res.data.FatFound;  
      Isform1.Hairs = res.data.Hairs; 
      Isform1.HoofColor = res.data.HoofColor;  
      Isform1.Angle = res.data.Angle;  
      Isform1.Sex = res.data.Sex;  
      Isform1.Breed = res.data.Breed;  
      Isform1.MeasureCottage = res.data.MeasureCottage;  
      Isform1.AgeDay = res.data.AgeDay;  
      Isform1.CreateBy = res.data.CreateBy;  
      Isform1.CreateDate = res.data.CreateDate;  
  })
}

//修改体尺
const UpdConditionMeasure = async (formEl: FormInstance | undefined) => {
  if (!formEl) return;
  await formEl.validate((valid, fields) => {
    if (valid) {
      http.post("first/api/Breeding/UpdateConditionMeasure", Isform1).then((res) => {
        if (res.data > 0) {
          ElMessage({
            message: "品相测定保存成功",
            type: "success",
          });
          dialogFormVisible1.value = false;
          GetConditionMeasure();
        } else {
          ElMessage({
            message: "品相测定保存失败",
            type: "error",
          });
        }
      });
    } else {
      console.log("error submit!", fields);
    }
  });
};
//查询集合
const form = reactive({
    Earbugles: "",
    Breed: "" ,
    Sex: "" ,
})
//分页
const page = {
  pageIndex: 1,
  pageSize: 10,
  totalCount: 0,
  pageCount: 0
}
const handleSizeChange = (sel: any) => {
  page.pageSize = sel;
  GetConditionMeasure();
}
const handleCurrentChange = (sel: any) => {
  page.pageIndex = sel;
  GetConditionMeasure();
}
//品相列表
const ConditionMeasureList=ref([])
//显示品相列表
const GetConditionMeasure = () => {
    http.get("srout/api/Breeding/GetConditionMeasure", {
    params: {
      pageIndex:page.pageIndex,
      pageSize:page.pageSize,
      Earbugles: form.Earbugles||null,
      Breed: form.Breed || null,
      Sex: form.Sex || null,
    }
  }).then(res => {  
    ConditionMeasureList.value = res.data.datas;
    page.totalCount = res.data.totalCount;
    page.pageCount = res.data.pageCount;
  })
}
const EditEar = () => {
  http.get("MYroute/api/SheepFile/SheepFileConditionFinds?card="+Isform.Earbugles)
  .then(res=>{
    Isform.Breed = res.data.breed;
    Isform.MeasureCottage = res.data.cottage;
    Isform.MeasureField = res.data.field;
    Isform.Sex = res.data.sex;
  })
}

const EditEarEdit = () => {
  http.get("MYroute/api/SheepFile/SheepFileConditionFinds?card="+Isform1.Earbugles)
  .then(res=>{
    Isform1.Breed = res.data.breed;
    Isform1.Sex = res.data.sex;    
    Isform1.MeasureCottage = res.data.cottage;
    Isform1.MeasureField = res.data.field;
  })
}


//牙齿咬合
const ToothTypeList=ref([
  {
    value: "",
    name: "",
  },
]);
//色斑
const StainList=ref([
  {
    value: "",
    name: "",
  },
]);
//嘴颜色
const MouthColorList=ref([
  {
    value: "",
    name: "",
  },
]);
//脂肪分布
const FatFoundList=ref([
  {
    value: "",
    name: "",
  },
]);
//毛发
const HairsList=ref([
  {
    value: "",
    name: "",
  },
]);
//蹄颜色
const HoofColorList=ref([
  {
    value: "",
    name: "",
  },
]);
//角
const AngleList=ref([
  {
    value: "",
    name: "",
  },
]);

const GetBody=()=>{
    //性别
    http.get("srout/api/Breeding/GetSex").then((res) => {
        SexList.value = res.data;
    });
    //品种
    http.get("srout/api/Breeding/GetBreed").then((res) => {
        BreedList.value = res.data;
    });
    //嘴颜色
    http.get("srout/api/Breeding/GetToothType").then((res) => {
        ToothTypeList.value = res.data;
    });
    //色斑
    http.get("srout/api/Breeding/GetStain").then((res) => {
        StainList.value = res.data;
    });
    //嘴颜色
    http.get("srout/api/Breeding/GetMouthColor").then((res) => {
        MouthColorList.value = res.data;
    });
    //脂肪分布  
    http.get("srout/api/Breeding/GetFatFound").then((res) => {
        FatFoundList.value = res.data;
    });
    //毛发
    http.get("srout/api/Breeding/GetHairs").then((res) => {
        HairsList.value = res.data;
    });
    //蹄颜色
    http.get("srout/api/Breeding/GetHoofColor").then((res) => {
        HoofColorList.value = res.data;
    });
    //角
    http.get("srout/api/Breeding/GetAngle").then((res) => {
        AngleList.value = res.data;
    });
}
//耳号
const ear=ref()
//耳号下拉框
const earlist=()=>{
  http.get("MYroute/api/SheepFile/SheepFileConditionEard").then(res=>{
    ear.value=res.data;
  })
}
//品种下拉框
const BreedList = ref([
  {
    value: "",
    name: "",
  },
]);
//性别下拉框
const SexList = ref([
  {
    value: "",
    name: "",
  },
]);

// --------------------------------？钩子函数
onMounted(() => {  
    GetBody();
  earlist();
    GetConditionMeasure();
})
</script>
<style >
    
</style>